package test;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

@WebServlet("/s")
public class SearchUser extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
       // List list;
        resp.setContentType("text/html;charset=utf-8");
        List<User> users =new ArrayList<>();
        users.add(new User("张三","1"));
        users.add(new User("杨跃森","6"));
        req.setAttribute("userList",users);

        for (User i:
             users) {
            resp.getWriter().write("<hi>姓名："+i.getName()+"-------年龄"+i.getAge()+"</br>");
        }



    }
}
